package LeiHeiDuiXiang.LeiHeDuiXiang3;

import javax.jws.soap.SOAPBinding;

class Student{
    private String name="wangda";
    private int age;
    private double score;
    private static String className="115";

    //当类加载的时候 就会被触发(实例化,访问静态成员变量)
    static {
        //定义在类当中，方法的外边 一般用来初始化静态的成员变量
        className="114";
        //name="fafa";error
        System.out.println("静态代码块当中 一"+
                "般用来初始化静态成员变量...");
    }

    {
        this.name="gaobo";
        System.out.println("实例代码块");
    }

    public Student(String name,int age,double score){
        this.name=name;
        this.age=age;
        this.score=score;
        //className="FDSAF";
        System.out.println("构造方法执行了...");
    }

    public Student(){
        System.out.println("Student()构造方法执行力...");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }


    public static void setClassName(String className) {
        Student.className = className;
    }

    public void doClass(){
        System.out.println(this.name+"正在上课....");
    }

    public void show(){
        System.out.println("姓名"+this.name+"年龄"
                    +this.age+"成绩："+this.score
                    +"班级名称"+className);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    /*
    静态成员方法->类方法->不依赖于对象
     */
    public static String getClassName() {
        //this.name="fsfsa";error
        //Student student=new Student("lisi",10,12.4);
        //student.show();
        return className;
    }
}

public class leiHeDuiXiangFuXi {
    public static void main1(String[] args) {
        Student student1=new Student("lisi",10,12.4);
        System.out.println(student1.toString());
    }

    public static void main2(String[] args) {
        Student student21=new Student();
        System.out.println("========");
        Student student22=new Student();

        System.out.println(student21.getName());
    }

    public static void main3(String[] args) {
        {
            int a=20;
            System.out.println(a);
        }
        //System.out.println/(a);//不包含在作用域当中
    }

    public static void main4(String[] args) {
        Student student41=null;
        System.out.println(student41.getClassName());
    }

    public static int add(int a,int b){
        if(a>10){
        }
        return a+b;
    }

    public static void main5(String[] args) {
        System.out.println(add(1,2));
        System.out.println(Student.getClassName());
    }

    public static void main(String[] args) {
        Student student61=new Student("lisi",10,12.4);
        student61.show();

        Student student62=new Student("zhangsan",5,90);
        student62.show();

        Student student63=new Student("wangwu ",60,80);
        student63.show();
    }
}
